package edu.nf.project.webs.storeOperation;

import edu.nf.project.entitys.dto.storeOperation.DishDTO;
import edu.nf.project.entitys.entity.storeOperation.convention.dish.Dish;
import edu.nf.project.services.exception.derivedAnomalies.DishException;
import edu.nf.project.services.response.BaseController;
import edu.nf.project.services.response.ResultVO;
import edu.nf.project.services.storeOperation.DishDTOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author gjh
 * @Date 2025/6/11
 * @Description: 菜品信息控制器
 */
@RestController
@RequestMapping("/api/dishesDTO")
public class DishDTOController extends BaseController {
    @Autowired
    private DishDTOService dishDTOService;

    /**
     * 获取所有菜品列表
     * @return 菜品列表信息
     */
    @GetMapping("/list")
    public ResultVO<List<DishDTO>> getDishList() {
        try {
            List<DishDTO> list = dishDTOService.getDishList();
            return success(list);
        } catch (Exception e) {
            if (e instanceof DishException) {
                throw e;
            }
            throw new DishException(40000, "系统错误，请稍后重试");
        }
    }
}
